package com.xpertline.ui.food;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class ListFoodPane extends JPanel {
	private JTable table;

	/**
	 * Create the panel.
	 */
	public ListFoodPane() {
		setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		FlowLayout flowLayout = (FlowLayout) panel.getLayout();
		flowLayout.setAlignment(FlowLayout.LEFT);
		add(panel, BorderLayout.NORTH);
		
		JButton btnHinTtC = new JButton("Hi\u1EC7n t\u1EA5t c\u1EA3");
		btnHinTtC.setPreferredSize(new Dimension(100, 25));
		panel.add(btnHinTtC);
		
		JButton btnXa = new JButton("X\u00F3a");
		btnXa.setPreferredSize(new Dimension(100, 25));
		panel.add(btnXa);
		
		JButton btnThm = new JButton("Th\u00EAm");
		btnThm.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EditFoodDialog dialog = new EditFoodDialog();
				dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
				dialog.setVisible(true);
			}
		});
		btnThm.setPreferredSize(new Dimension(100, 25));
		panel.add(btnThm);
		
		JButton btnTiTnhTn = new JButton("T\u00E1i t\u00EDnh t\u1ED3n kho");
		btnTiTnhTn.setPreferredSize(new Dimension(120, 25));
		panel.add(btnTiTnhTn);
		
		JScrollPane scrollPane = new JScrollPane();
		add(scrollPane, BorderLayout.CENTER);
		
		table = new JTable();
		table.setRowHeight(20);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
			},
			new String[] {
				"M\u00E3 th\u1EE9c \u0103n", "T\u00EAn th\u1EE9c \u0103n", "Gi\u00E1 b\u00E1n", "Nguy\u00EAn gi\u00E1", "T\u1ED3n kho", "T\u1ED3n kho t\u1ED1i thi\u1EC3u"
			}
		) {
			Class[] columnTypes = new Class[] {
				String.class, String.class, Object.class, Object.class, Object.class, Object.class
			};
			public Class getColumnClass(int columnIndex) {
				return columnTypes[columnIndex];
			}
		});
		table.getColumnModel().getColumn(0).setPreferredWidth(85);
		table.getColumnModel().getColumn(1).setPreferredWidth(152);
		table.getColumnModel().getColumn(2).setPreferredWidth(79);
		table.getColumnModel().getColumn(3).setPreferredWidth(101);
		table.getColumnModel().getColumn(4).setPreferredWidth(97);
		table.getColumnModel().getColumn(5).setPreferredWidth(110);
		table.setFillsViewportHeight(true);
		scrollPane.setViewportView(table);

	}

}
